<template>
  <div>   
    <h1>员工财务报表</h1>
    <div id="main" style="width: 600px; height: 600px"></div>
  </div>
</template>

<script>
export default {
    // name: "c1",
  data() {
    return {
        AccountEchartsList2:[],
        AccountEchartsList3:[],
        a:[],
        b:[]
    };
  },
  mounted() {    
    this.AccountEcharts1();
    this.AccountEcharts2();
  },
  methods: {
    AccountEcharts1(){
        this.$axios.get("company/quereyEcharts2")
        .then(res=>{
             
            this.AccountEchartsList2 = res.data.data.AccountEchartsList2;
             for(var obj in  this.AccountEchartsList2)
      {
        this.a.push(this.AccountEchartsList2[obj].name);
        this.b.push(this.AccountEchartsList2[obj].value)
      }
            this.getChar();
             
        })
    },
    AccountEcharts2(){
        this.$axios.get("company/quereyEcharts3")
        .then(res=>{
             
            this.AccountEchartsList3 = res.data.data.AccountEchartsList3;
            this.getChar();
             
        })
    },
    getChar() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = this.$echarts.init(document.getElementById("main"));
      // 指定图表的配置项和数据
        var option = {
  xAxis: {
    type: 'category',
    data: this.a
    // data:this.AccountEchartsList2
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: this.b,
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      }
    }
  ]
};
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
  },
};
</script>